How to check memory
There are several ways to check memory of a linux server. There are meminfo, top, vmstat, and free.
cat /proc/meminfo
The first is cat /proc/meminfo. Meminfo will show you everything about memory status of the Linux server in raw data. Total memory, free memory, available memory, buffers, cache, active and inactive.
The below information is an example of what you will see when you use meminfo.
MemTotal: 594900 kB
MemFree: 64500 kB
MemAvailable: 316728 kB
Buffers: 49568 kB
Cached: 262412 kB
SwapCached: 0 kB
Active: 258940 kB
Inactive: 144904 kB
Active(anon): 92296 kB
Inactive(anon): 428 kB
Active(file): 166644 kB
Inactive(file): 144476 kB
Unevictable: 0 kB
Mlocked: 0 kB
SwapTotal: 0 kB
SwapFree: 0 kB
Dirty: 12 kB
Writeback: 0 kB
AnonPages: 91904 kB
Mapped: 36320 kB
Shmem: 860 kB
Slab: 71748 kB
SReclaimable: 41740 kB
SUnreclaim: 30008 kB
KernelStack: 1884 kB
PageTables: 4496 kB
NFS_Unstable: 0 kB
Bounce: 0 kB
WritebackTmp: 0 kB
CommitLimit: 297448 kB
Committed_AS: 462648 kB
VmallocTotal: 34359738367 kB
VmallocUsed: 0 kB
VmallocChunk: 0 kB
HardwareCorrupted: 0 kB
AnonHugePages: 0 kB
ShmemHugePages: 0 kB
ShmemPmdMapped: 0 kB
CmaTotal: 0 kB
CmaFree: 0 kB
HugePages_Total: 0
HugePages_Free: 0
HugePages_Rsvd: 0
HugePages_Surp: 0
Hugepagesize: 2048 kB
DirectMap4k: 111984 kB
DirectMap2M: 516096 kB
DirectMap1G: 0 kB
top
The second is top, which shows what memory is used by the user (including root) by command, and it's always active until you type in CTRL+C. The stats you see when you use top are live, meaning that it's always active.
Top provides a real time summary of the top users of your server's resources.
Load average: three numbers that roughly relefect demand for your CPUs on the system (1,5,15 minutes) if it's higher than the # of the Cpus you have, that's often bad.
Memory: 4 numbers: total/fre/used/cached. One perhaps unexpeted thing: Total is not free+used but free+used+ + filesystem cache
%CPU: this colum is given as % of a single core. If you have 4 cores, this can go up to 400%.
RES: or resident set size aka how much memory your process is using
SHR is how much of the RES is shared with other processes.
Htop is merely a prettier version of top where it actually shows you graphs.
vmstat
vmstat shows you a shows you asimple version of what memory is available on your server. Stats listed are memory, swap, ic system, and cpu
free
Free Just shows total used, free, shared buff/cahe and available memory of the system.